using ControlCenter.Data.Interfaces;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using MingYuanYun.Data.Abstractions;

namespace ControlCenter.Data
{
    public static class RepositoryServiceCollectionExtensions
    {
        public static IServiceCollection AddRepositories(this IServiceCollection services, IConfiguration configuration)
        {
            services.AddTransient<IUnitOfWork>(p => new UnitOfWork(configuration.GetSection("ConnectionStrings").AsEnumerable(true), Driver.SqlServer));
            services.AddScoped<IPackageManagementRepository, PackageManagementRepository>();
            services.AddScoped<IPackageConfigRepository, PackageConfigRepository>();
            services.AddScoped<IRobotRepository, RobotRepository>();
            services.AddScoped<IExecutionQueueRepository, ExecutionQueueRepository>();
            services.AddScoped<IMyUsersRepository, MyUsersRepository>();
            services.AddScoped<IParamSettingRepository, ParamSettingRepository>();
            services.AddScoped<IHeartLogRepository, HeartLogRepository>();
            return services;
        }
    }
}
